package com.mmall.dao;

import com.mmall.common.ServerResponse;
import com.mmall.pojo.User;
import org.apache.ibatis.annotations.Param;

public interface UserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    int checkUsername(String username);

    int checkEmail(String email);

    //在mybatis中，如果有多个参数，需要添加@Params注解，@Params(参数) 中的参数与数据库中的字段名保持一致
    User selectLogin(@Param("username") String username, @Param("password") String password);

    String selectQuestionByUsername(String username);

    int checkAnswer(@Param("username") String username, @Param("question") String question, @Param("answer") String answer);

    int updatePasswordByUserName(@Param("username") String username, @Param("passwordNew") String passwordNew);

    int checkPassword(@Param("passwordOld")String password,@Param("userId")int userId);//这里用integer 和int 都可以

    int checkEmailById(@Param("email") String email,@Param("userId")int userId);
}